﻿using GalaSoft.MvvmLight.Ioc;
using System.Collections.Generic;
using TabbedTemplate.Services;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace TabbedTemplate.Views
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class CityLocations : ContentPage
    {

        private readonly IDataService _dataService;

        public CityLocations()
        {

            _dataService = SimpleIoc.Default.GetInstance<IDataService>();
            InitializeComponent();
        }

        private async void Cities_OnTextChanged(object sender, TextChangedEventArgs e)
        {
            List<string> list = await _dataService.GetCitySearchResult(e.NewTextValue);

            if (list.Count == 0)
                Status.Text = "暂无更多搜索结果";
            Cities.ItemsSource = list;
        }
    }
}
